{% load static %}
{% load utils %}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<title>区块管理</title>
<link rel="stylesheet" href="{% static '/public/css/ui.css' %}">
<link rel="stylesheet" href="{% static '/public/admin/css/layout.css' %}">
<script src="{% static '/public/js/jquery.js' %}"></script>
<script src="{% static '/public/js/ui.js' %}"></script>
</head>

<body>
    <div class="position">当前位置：内容管理 > <a href="/manager/block/index/">区块管理</a></div>
    <div class="border">
        <!---->
        <a href="/manager/block/add/" class="ui-btn ui-btn-info ui-mr-sm ui-mb">添加区块</a>

        <div class="ui-table-wrap">
        <table class="ui-table ui-table-border ui-table-hover ui-table-striped ui-mb">
            <thead class="ui-thead-gray">
                <tr>
                    <th>区块说明</th>
                    <th width="300">关键字</th>
                    <th width="180">创建时间</th>
                    <th width="240">修改时间</th>
                    <th width="120">操作</th>
                </tr>
            </thead>
            <tbody>
            {% if not block_items %}
            <tr>
                <td colspan="5">暂无区块</td>
            </tr>
            {% endif %}
            {% for block in block_items %}
            <tr>
                <td class="ui-text-left">{{block.title}}</td>
                <td>{{block.key}}</td>
                <td>{{ block.create_time|date:"Y-m-d H:i:s" }}</td>
                <td>{{ block.update_time|date:"Y-m-d H:i:s" }}</td>
                <td><a href="/manager/block/edit?id={{block.id}}"><span class="ui-icon-edit"></span> 编辑</a>　<a href="javascript:;" class="del" data-url="/manager/block/del?id={{block.id}}"><span class="ui-icon-delete"></span> 删除</a></td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
        </div>
        <!---->
    </div>
<script>
$(function()
{
	$(".block").each(function(e){
		var key=$(this).attr("config");
		var html='{';
		html+='block("';
		html+=key;
		html+='")}';
		$(this).attr("value",html);
	})
	$(".del").click(function()
	{
		var url=$(this).attr("data-url");
		$.dialog(
		{
			'title':"操作提示",
			'text':"确定要删除？不可恢复！",
			'oktheme':'ui-btn-info',
			'ok':function(e)
			{
				$.ajax(
				{
                    url:url,
					type:'post',
					dataType:'json',
					data:'token={$token}',
					error:function(e){alert(e.responseText);},
                    success:function(d)
                    {
                        e.close();
                        if(d.state=='success')
                        {
                            wmcms.success(d.msg);
                            setTimeout(function(){location.href='{THIS_LOCAL}';},1000);
                        }
                        else
                        {
                            wmcms.error(d.msg);
                        }
                    }
                });
			}
		});
    });
})
</script>
</body>
</html>